<template>
  <div>
    <p>用户名：{{ $store.state.name }}</p>
    <br />
    <br />
    <br />
    <p>余额：{{ $store.state.money }}</p>
    <button @click="recharge(5)">充值5元</button>
    <button @click="recharge(10)">充值10元</button>
    <br />
    <input type="text" v-model.number="num" />
    <button @click="recharge(num)">自定义充值</button>
  </div>
</template>

<script>
import {ADD} from '../store/mutation-type'
export default {
  data() {
    return {
      username: "",
      num: 0,
    };
  },
  methods: {
    recharge(num) {
      console.log(num);
      this.$store.commit(ADD, num);
    },
  },
};
</script>

<style>
</style>